//
//	 ______    ______    ______    
//	/\  __ \  /\  ___\  /\  ___\   
//	\ \  __<  \ \  __\_ \ \  __\_ 
//	 \ \_____\ \ \_____\ \ \_____\ 
//	  \/_____/  \/_____/  \/_____/ 
//
//	Powered by BeeFramework
//
//
//  UserDetailBoard.m
//  iHeima
//
//  Created by he chao on 5/30/14.
//  Copyright (c) 2014 leon. All rights reserved.
//

#import "UserDetailBoard.h"
#import "ChatBoard.h"

#pragma mark -

@interface UserDetailBoard()
{
	//<#@private var#>
}
@end

@implementation UserDetailBoard
DEF_SIGNAL(SEND_MSG)

- (void)load
{
}

- (void)unload
{
}

#pragma mark - Signal

ON_CREATE_VIEWS( signal )
{
    self.title = self.dictUser[@"username"];
    self.navigationController.navigationBarHidden = NO;
    [self showBarButton:BeeUINavigationBar.LEFT image:IMAGESTRING(@"navi_back")];
    [self showNaviBar];
    [self loadContent];
}

ON_DELETE_VIEWS( signal )
{
}

ON_LAYOUT_VIEWS( signal )
{
}

ON_WILL_APPEAR( signal )
{
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}

ON_DID_APPEAR( signal )
{
}

ON_WILL_DISAPPEAR( signal )
{
}

ON_DID_DISAPPEAR( signal )
{
}

ON_SIGNAL3( BeeUINavigationBar, LEFT_TOUCHED, signal )
{
    [self.stack popBoardAnimated:YES];
}

ON_SIGNAL3( BeeUINavigationBar, RIGHT_TOUCHED, signal )
{
}

ON_SIGNAL2(UserDetailBoard,signal){
    if ([signal is:UserDetailBoard.SEND_MSG]) {
        ChatBoard *board = [[ChatBoard alloc] init];
        board.dictUser = self.dictUser;
        [self.stack pushBoard:board animated:YES];
    }
}

- (void)loadContent{
    BeeUIImageView *imgTab = [BeeUIImageView spawn];
    imgTab.frame = CGRectMake(0, self.viewHeight-(IOS7_OR_LATER?64:0)-50, self.viewWidth, 50);
    imgTab.image = IMAGESTRING(@"tab_bg");
    imgTab.contentMode = UIViewContentModeScaleToFill;
    imgTab.userInteractionEnabled = YES;
    [self.view addSubview:imgTab];
    
    BeeUIButton *btn = [BeeUIButton spawn];
    btn.frame = imgTab.bounds;
    [btn setImage:IMAGESTRING(@"send_msg") forState:UIControlStateNormal];
    [btn addSignal:UserDetailBoard.SEND_MSG forControlEvents:UIControlEventTouchUpInside];
    [imgTab addSubview:btn];
    
    BeeUIWebView *myWebView = [BeeUIWebView spawn];
    myWebView.url = [NSString stringWithFormat:@"http://dev.iheima.com/2/heimaship/index/uid/%@",self.dictUser[@"uid"]];
    
//     myWebView.url = [NSString stringWithFormat:@"http://dev.iheima.com/2/heimaship/index/uid/8377"];
    myWebView.frame = CGRectMake(0, 0, self.viewWidth, self.viewHeight-(IOS7_OR_LATER?64:44)-50);
    [self.view addSubview:myWebView];
    
    //
}

@end
